package kr.hkit.powerjava.chapter22.work2.vo;

public class Student  implements Comparable<Student>{
	private int stdNum;
	private String stdName;
	private int kor;
	private int eng;
	private int math;
	//생성자2개
	public Student(int stdNum, String stdName, int kor, int eng, int math) {
		super();
		this.stdNum = stdNum;
		this.stdName = stdName;
		this.kor = kor;
		this.eng = eng;
		this.math = math;
	}//getter/setter
	
	public int getStdNum() {
		return stdNum;
	}
	public void setStdNum(int stdNum) {
		this.stdNum = stdNum;
	}
	public String getStdName() {
		return stdName;
	}
	public void setStdName(String stdName) {
		this.stdName = stdName;
	}
	public int getKor() {
		return kor;
	}
	public void setKor(int kor) {
		this.kor = kor;
	}
	public int getEng() {
		return eng;
	}
	public void setEng(int eng) {
		this.eng = eng;
	}
	public int getMath() {
		return math;
	}
	public void setMath(int math) {
		this.math = math;
	}
	public Student(int stdNum, String stdName) {
		super();
		this.stdNum = stdNum;
		this.stdName = stdName;
	}


	public double getTotal(){
		return kor+eng+math;
	}
	public double getAvg(){
		return getTotal()/3.0;
	}
	
	@Override
	public boolean equals(Object obj) {
		Student std=(Student)obj;
		return(stdNum==std.stdNum && stdName.equals(std.stdName));
	}

	@Override
	public String toString() {
		return String
				.format("%3s\t%5s\t%3s\t%3s\t%3s\t%5.2f\t%5.2f",
						stdNum, stdName, kor, eng, math, getTotal(), getAvg());
	}
//총점순 정렬
	@Override
	public int compareTo(Student o) {
		return (int)(getTotal()-o.getTotal());
	}
}
